class Solution {
    public:
        int minimumRecolors(string blocks, int k) {
            int temp=0;
            for(int i=0;i<k;i++){
                if(blocks[i]=='W'){
                    temp++;
                }
            }
            int ans=temp;
    
            for(int i=k;i<blocks.length();i++){
                if(blocks[i]=='W'){
                    temp++;
                }
                if(blocks[i-k]=='W'){
                    temp--;
                }
                ans=min(ans,temp);
            }
            return ans;
        }
    };